import {defineStore} from 'pinia'
import type {Question} from "@/types/schema"

interface QuestionState {
    questionList: Question[]
    currentQueIndex: number
}

export const useQuestionStore = defineStore('question', {
    state: (): QuestionState => {
        return {
            questionList: [],
            currentQueIndex: -1,
        }
    },
    getters: {
        currentQue() {
            if (this.currentQueIndex >= 0) {
                return this.questionList[this.currentQueIndex]
            }
        }
    },
    actions: {
        setCurrentQueIndex(index: number) {
            this.currentQueIndex = index
        },
        addQuestion(data: Question) {
            this.questionList.push(data)
        },
    },
})